package com.common.model.enums;

/**
 * 通用系统错误码：00、99开头
 * @ClassName: ErrorCode  
 * @Description: TODO(这里用一句话描述这个类的作用)  
 * @author "Linfeng Han"  
 * @date 2017年1月5日 上午10:03:29
 *
 */
public enum ErrorCode {

	SUCCESS("SUCCESS", "成功"),
	FAILED("FAIL", "服务异常"),
	FAILED_KINDLECP_JSCODE2SESSION("000001", "code 换取 session_key 异常"),
	FAILED_KINDLECP_SESSION_3RD_EXPIRE("000002", "SESSION_3RD 超时"),
	FAILED_KINDLECP_CODE_IS_NULL("000003", "code 为空"),
	FAILED_KINDLECP_SIGNATUR_IS_ERROR("000004","用户信息不完整 或 session_3rd错误"),
	FAILED_KINDLECP_URLDECODER_EXCEPTION("000005", "URLDECODER_EXCEPTION"),
//	FAILED_KINDLECP_DECRYPT_ERROR("000005", "解码失败"),
	FAILED_KINDLECP_SESSION_3RD_IS_NULL("000006", "SESSION_3RD 为空"),
	FAILED_KINDLECP_USERINFORAWDATA_IS_NULL("000007", "userInfoRawData 为空"),
	FAILED_KINDLECP_USERINFOENCRYPTEDDATA_IS_NULL("000008", "userInfoEncryptedData 为空"),
	FAILED_KINDLECP_USERINFOIV_IS_NULL("000009", "userInfoIv 为空"),
	FAILED_KINDLECP_USERINFOSIGNATURE_IS_NULL("000010", "userInfoSignature 为空"),
//	FAILED_KINDLECP_OPENGIDENCRYPTEDDATA_IS_NULL("000009","openGIdEncryptedData 为空"),
//	FAILED_KINDLECP_OPENGIDIV_IS_NULL("000010", "openGIdIv 为空"),
//	FAILED_KINDLECP_USER_IS_SIGN("000011", "用户已签到"),
//	FAILED_KINDLECP_USER_IS_SIGNEW("000011", "用户今日未签到"),
//	FAILED_KINDLECP_USER_SIGN_COMMIT("000012","用户签到失败"),
//	FAILED_CHEECK_SIGLE_DATA("000013","查询单个数据失败"),
//	FAILED_JS_CODE2_SESSION_EXPIRE("000014","redis session 过期"),
//	FAILED_RECEIVE_FINANCIAL_PLANNER("000015","userId 为空 ")
	;
	
	private String code = null;
	private String msg = null;
	ErrorCode(String code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public String getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public static ErrorCode getByCode(String code) {
		if (code == null || code.isEmpty()) {
			return null;
		}

		ErrorCode[] enums = ErrorCode.values();
		for (ErrorCode p : enums) {
			if (p.getCode().equals(code)) {
				return p;
			}
		}

		return null;
	}
}